﻿using Autodesk.Revit.DB;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Bcpg.Sig;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using ZhuXingFamilys.ExportExcel.entity;
using ZhuXingFamilys.ExportExcel.utils;
using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System;

namespace ZhuXingFamilys.ExportExcel
{
    [DataContract]
    [Serializable]
    public class excelData : INotifyPropertyChanged, ICloneable
    {
        [field: NonSerializedAttribute()]
        public event PropertyChangedEventHandler PropertyChanged;
        private int _id; //序号
        private string _elementId; //族ID
        private string _typeId; // 类型ID
        private string _type; //类型
        private string _familyNumber; //族库编号
        private int _specialitieId; // 专业id
        private string _code; //项目编号
        private string _name; //项目名称
        private string _category; //类别
        private string _elevation; //标高
        private string _floor; //楼层
        private double _volume; //体积
        private double _area; //面积
        private double _length; //长度
        private string _features; //项目特征
        private string _quantitiesname; //工程量名称
        private double _num; //工程数量
        private string _company; //计量单位
        private int _numCount; //计量数量
        // 工程量名称切换
        private List<string> _unitList = selectDateDictionary.QuantitiesnameType();
        public excelData()
        {
            _id = Id; 
            _elementId = elementId;
            _typeId = TypeId;
            _type = Type;
            _familyNumber = FamilyNumber;
            _specialitieId = SpecialitieId;
            _code = Code;
            _name = Name;
            _category = Category;
            _elevation = Elevation;
            _floor = Floor;
            _volume = Volume;
            _area = Area;
            _length = Length;
            _features = Features;
            _quantitiesname = Quantitiesname;
            _num = Num;
            _company = Company;
            _numCount = NumCount;
            _unitList = UnitList;
        }

        [ExcelColumn("序号")]
        [DataMember(Order = 0)]
        public int Id
        {
            get { return _id; }
            set
            {
                _id = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Id"));
            }
        }

        [DataMember(Order = 1)]
        public string TypeId
        {
            get { return _typeId; }
            set
            {
                _typeId = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TypeId"));
            }
        }
        [DataMember(Order = 2)]
        public string Type
        {
            get { return _type; }
            set
            {
                _type = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Type"));
            }
        }
        [DataMember(Order = 3)]
        public string elementId
        {
            get { return _elementId; }
            set
            {
                _elementId = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("elementId"));
            }
        }

        [DataMember(Order = 4)]
        public string FamilyNumber
        {
            get { return _familyNumber; }
            set
            {
                _familyNumber = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("FamilyNumber"));
            }
        }
        [DataMember(Order = 5)]
        public int SpecialitieId
        {
            get { return _specialitieId; }
            set
            {
                _specialitieId = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialitieId"));
            }
        }
        [DataMember(Order = 6)]
        [ExcelColumn("项目编号")]
        public string Code
        {
            get { return _code; }
            set
            {
                _code = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Code"));
            }
        }
        [DataMember(Order = 7)]
        [ExcelColumn("项目名称")]
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
            }
        }
        [DataMember(Order = 8)]
        public string Category
        {
            get { return _category; }
            set
            {
                _category = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Category"));
            }
        }
        [DataMember(Order = 9)]
        public string Elevation
        {
            get { return _elevation; }
            set
            {
                _elevation = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Elevation"));
            }
        }
        [DataMember(Order = 10)]
        public string Floor
        {
            get { return _floor; }
            set
            {
                _floor = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Floor"));
            }
        }
        [DataMember(Order = 11)]
        public double Volume
        {
            get { return _volume; }
            set
            {
                _volume = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Volume"));
            }
        }

        [DataMember(Order = 12)]
        public double Area
        {
            get { return _area; }
            set
            {
                _area = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Area"));
            }
        }
        [DataMember(Order = 13)]
        public double Length
        {
            get { return _length; }
            set
            {
                _length = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Length"));
            }
        }
        [DataMember(Order = 14)]
        [ExcelColumn("项目特征")]
        public string Features
        {
            get { return _features; }
            set
            {
                _features = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Features"));
            }
        }
        [DataMember(Order = 15)]
        [ExcelColumn("工程量名称")]
        public string Quantitiesname
        {
            get { return _quantitiesname; }
            set
            {
                _quantitiesname = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Quantitiesname"));
            }
        }
        [DataMember(Order = 16)]
        [ExcelColumn("工程数量")]
        public double Num
        {
            get { return _num; }
            set
            {
                _num = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Num"));
            }
        }
        [DataMember(Order = 17)]
        [ExcelColumn("计量单位")]
        public string Company
        {
            get { return _company; }
            set
            {
                _company = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Company"));
            }
        }
        [DataMember(Order = 18)]
        public int NumCount
        {
            get { return _numCount; }
            set
            {
                _numCount = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("NumCount"));
            }
        }
        [DataMember(Order = 19)]
        public List<string> UnitList
        {
            get { return _unitList; }
            set
            {
                _unitList = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("UnitList"));
            }
        }

        public override string ToString()
        {
            return "id:" + _id + "\n" +
                   "elementId:" + _elementId + "\n" +
                   "TypeId:" + _typeId + "\n" +
                   "FamilyNumber:" + _familyNumber + "\n" +
                   "Code:" + _code + "\n" +
                   "Name:" + _name + "\n" +
                   "Elevation:" + _elevation + "\n" +
                   "Volume:" + _volume + "\n" +
                   "Area:" + _area + "\n" +
                   "Features:" + _features + "\n" +
                   "Quantitiesname:" + _quantitiesname + "\n" +
                   "Num:" + _num + "\n" +
                   "Company:" + _company + "\n" +
                   "NumCount:" + _numCount;
        }

        public object Clone()
        {
            return this;
        }
        // override object.Equals
        //public override bool Equals(object obj)
        //{
        //    if (obj == null || GetType() != obj.GetType())
        //    {
        //        return false;
        //    }
        //    excelData excel = (excelData)obj;
        //    if (excel.TypeId.Equals(TypeId) && excel.FamilyNumber.Equals(FamilyNumber))
        //    {
        //        return true;
        //    }
        //    return false;
        //}

        //// override object.GetHashCode
        //public override int GetHashCode()
        //{
        //    return base.GetHashCode();
        //}
    }
}